﻿<%@ Page Title="TB Communications | Branch" Theme="POSSystem" Language="C#" MasterPageFile="~/Application.Master" AutoEventWireup="true" CodeBehind="Branches.aspx.cs" Inherits="WebUI.BranchList" %>

<%@ Register Src="~/Controls/POSControls/BranchListCtrl.ascx" TagName="BranchList" TagPrefix="uc" %>
<%@ Register Src="~/Controls/SysControls/PageHeader.ascx" TagPrefix="uc" TagName="PageHeader" %>
<%@ Register Src="~/Controls/POSControls/BranchRoleListCtrl.ascx" TagPrefix="uc" TagName="BranchRoleList"  %>

<asp:Content ID="Content1" ContentPlaceHolderID="ApplicationHeadHolder" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ApplicationContentHolder" runat="server">
     <uc:PageHeader ID="pageHeader" Text="Stock Locations" ImageURL="~/Images/icon_operational_branch_node.gif" runat="server" />
    <script type="text/javascript">
        function onAddBranch() {
            var id = getSelectedItemID<%=lstBranch.ClientID %>();
            var returnValue = window.showModalDialog('<%=GetBranchEditPageLink() %>' + 'mode=new', '', 'dialogWidth=480px;dialogHeight=300px;resizable=no;help=no;unadorned=yes;');

            return returnValue > 0;
        }

        function onEditBranch() {
            var id = getSelectedItemID<%=lstBranch.ClientID %>();
            if(id == null){
                alert("No item was selected!");
                return false;
            }
            var returnValue = window.showModalDialog('<%=GetBranchEditPageLink() %>' + 'mode=edit&id=' + id, '', 'dialogWidth=480px;dialogHeight=300px;resizable=no;help=no;unadorned=yes;');
            return returnValue > 0;
        }

        function onRemoveBranch() {
            var id = HasCheckedItems<%=lstBranch.ClientID %>();
            if(id == false){
                alert("No item was selected!");
                return false;
            }
            
            return confirm("Delete a branch will also delete all related information. Do you want to continue?");
        } 

        function lstBranch_OnClientClick(){
            var id = getSelectedItemID<%=lstBranch.ClientID %>();
            document.getElementById("divRole").style.display = "block";
            document.getElementById("<%= hidSelectedBranchID.ClientID %>").value = id;
            document.getElementById("<%= btnLoadByBranchID.ClientID %>").click();
        }

         function onSaveRole() {
            return confirm('Are you sure to save all changes?');
        }
    </script>
    <table width="100%">
        <tr>
            <td style="width: 25%; text-align: left; vertical-align: top">
                <asp:Panel ID="panelBranch" runat="server" class="primaryPanel">
                    <div class="titleBar">
                        <asp:Label ID="lblTitle1" runat="server" CssClass="titleContent">Stock List</asp:Label>
                    </div>
                    <div class="primaryFrameNoBorder">
                        <div>
                            <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                                <ContentTemplate>
                                    <table width="100%" class="toolbar">
                                        <tr>
                                            <td style='vertical-align: middle; width: 75px'>
                                                <asp:LinkButton class="tbbutton" ID="btnAddBranch" runat="server" OnClientClick="return onAddBranch();"
                                                    OnClick="btnAddBranch_OnClick">
                                                    <img src="~/Images/AddRecord.gif" runat="server" /><asp:Label ID="label2" runat="server" Text="Add"></asp:Label>
                                                </asp:LinkButton>
                                                <asp:LinkButton class="tbbutton" ID="btnEditBranch" runat="server" OnClientClick=" return onEditBranch();"
                                                    OnClick="btnAddBranch_OnClick">
                                                    <img src="~/Images/Edit.gif" runat="server" /><asp:Label ID="label3" runat="server" Text="Edit"></asp:Label>
                                                </asp:LinkButton>
                                                <asp:LinkButton class="tbbutton" ID="btnRemoveBranch" runat="server" OnClientClick="return onRemoveBranch();"
                                                    OnClick="btnRemoveBranch_OnClick">
                                                    <img src="~/Images/Delete.gif" runat="server" /><asp:Label ID="label4" runat="server" Text="Delete"></asp:Label>
                                                </asp:LinkButton>
                                            </td>
                                        </tr>
                                    </table>
                                    <asp:UpdatePanel ID="updateGridOrder" runat="server" UpdateMode="Conditional">
                                        <ContentTemplate>
                                            <uc:BranchList ID="lstBranch" Width="100%" runat="server" AllowPaging="true"
                                                AllowSorting="true" AllowSelecting="true" SaveOnCommit="false" />
                                        </ContentTemplate>
                                    </asp:UpdatePanel>

                                    <div style="height:20px">&nbsp;</div>

                                    <div id="divRole" style="display:none">
                                        <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
                                            <ContentTemplate>
                                                <table width="100%" class="toolbar">
                                                    <tr>
                                                        <td style='vertical-align: middle; width: 75px'>
                                                             <asp:LinkButton class="tbbutton" ID="btnEditRole" runat="server" OnClientClick=" return onSaveRole();"
                                                                OnClick="btnSaveRole_OnClick">
                                                                <img src="Images/save.gif" /><asp:Label ID="label6" runat="server" Text="Save"></asp:Label>
                                                            </asp:LinkButton>
                                                        </td>
                                                    </tr>
                                                </table>
                                                <uc:BranchRoleList ID="lstRole" Width="100%" runat="server" AllowPaging="false"
                                                    AllowSorting="false" AllowSelecting="true" SaveOnCommit="false" />
                                                <asp:Label ID="labelHint" runat="server" class='labelNote'>(*) Check modified roles and click save</asp:Label>
                                                <asp:HiddenField ID="hidSelectedBranchID" runat="server" />
                                                <asp:Button ID="btnLoadByBranchID" runat="server" style="display:none" OnClick="btnLoadByBranchID_OnClick"> </asp:Button>
                                            </ContentTemplate>
                                        </asp:UpdatePanel>
                                    </div>
                                </ContentTemplate>
                            </asp:UpdatePanel>
                        </div>
                    </div>
                </asp:Panel>
            </td>
        </tr>
    </table>
</asp:Content>
